@extends('admin.layout.app')

@section('title', '編輯角色')
@section('menu', broute('role.index'))

@section('content')
    <div class="layui-col-lg12">
        <div class="layui-card">
            <div class="layui-card-header">
                編輯角色
            </div>
            <div class="layui-card-body">
                <form class="layui-form" method="post" action="/role/edit">
                    <div class="layui-form-item">
                        <label class="layui-form-label">roleId</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="roleId" value="{{$role->id}}"/>
                            <input type="text"  disabled
                                   value="{{$role->id}}"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">名稱</label>
                        <div class="layui-input-block">
                            <input type="text" name="roleName"
                                   value="{{$role->name}}"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">權限</label>
                        <div class="layui-input-block">
                            <select lay-ignore name="permissions[]" xm-select="selectId"
                                    xm-select-search="">
                                @foreach($permissions as $permission)
                                    @if(in_array($permission->name,$ownPermission))
                                    <option value="{{$permission->id}}" selected>{{$permission->name}}</option>
                                    @else
                                        <option value="{{$permission->id}}">{{$permission->name}}</option>
                                    @endif
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit>提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

@endsection
